package avicit.ma.ma.na.demomain.api;

import avicit.ma.ma.na.demomain.dto.*;
import avicit.ma.ma.na.demomain.dto.DemoMainDTO;
import avicit.platform6.core.rest.msg.QueryReqBean;
import avicit.platform6.core.rest.msg.QueryReqBean;
import avicit.platform6.core.rest.msg.QueryRespBean;
import avicit.platform6.core.rest.msg.QueryRespBean;
import avicit.platform6.core.rest.msg.ResponseMsg;
import avicit.platform6.core.restclient.RestClient;
import avicit.platform6.core.restclient.RestClientUtils;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

/**
 * demoMainAPI类
 *
 * @author admin
 * @version V1.0.0
 * @date 2024-11-18 14:17:22
 * @since V1.0.0
 */
@Component
public class DemoMainAPI {

  /**
   * 服务编码
   */
  private static final String SERVICE_CODE = "ma-ma";

  private static final String BASE_PATH = "api/ma/na/demomain";

  @Autowired
  private RestClient restClient;

  public QueryRespBean<DemoMainDTO> findListByPage(QueryReqBean<DemoMainDTO> queryReqBean) {
    String url = BASE_PATH + "/find-list-by-page/v1";
    ResponseMsg<QueryRespBean<DemoMainDTO>> responseMsg = restClient.doPost(SERVICE_CODE, url, queryReqBean, new ParameterizedTypeReference<ResponseMsg<QueryRespBean<DemoMainDTO>>>() {
    });
    return RestClientUtils.getResponseBody(responseMsg);
  }

  public List<DemoMainDTO> findList(QueryReqBean<DemoMainDTO> queryReqBean) {
    String url = BASE_PATH + "/find-list/v1";
    ResponseMsg<List<DemoMainDTO>> responseMsg = restClient.doPost(SERVICE_CODE, url, queryReqBean, new ParameterizedTypeReference<ResponseMsg<List<DemoMainDTO>>>() {
    });
    return RestClientUtils.getResponseBody(responseMsg);
  }

  public DemoMainDTO getById(String id) {
    String url = BASE_PATH + "/get/" + id + "/v1";
    ResponseMsg<DemoMainDTO> responseMsg = restClient.doGet(SERVICE_CODE, url, new ParameterizedTypeReference<ResponseMsg<DemoMainDTO>>() {
    });
    return RestClientUtils.getResponseBody(responseMsg);
  }

  public String save(DemoMainDTO demoMain) {
    String url = BASE_PATH + "/save/v1";
    ResponseMsg<String> responseMsg = restClient.doPost(SERVICE_CODE, url, demoMain, new ParameterizedTypeReference<ResponseMsg<String>>() {
    });
    return RestClientUtils.getResponseBody(responseMsg);
  }

  public Integer updateSensitive(DemoMainDTO demoMain) {
    String url = BASE_PATH + "/update-sensitive/v1";
    ResponseMsg<Integer> responseMsg = restClient.doPut(SERVICE_CODE, url, demoMain, new ParameterizedTypeReference<ResponseMsg<Integer>>() {
    });
    return RestClientUtils.getResponseBody(responseMsg);
  }

  public Integer updateAll(DemoMainDTO demoMain) {
    String url = BASE_PATH + "/update-all/v1";
    ResponseMsg<Integer> responseMsg = restClient.doPut(SERVICE_CODE, url, demoMain, new ParameterizedTypeReference<ResponseMsg<Integer>>() {
    });
    return RestClientUtils.getResponseBody(responseMsg);
  }

  public Integer deleteById(String id) {
    String url = BASE_PATH + "/delete-by-id/" + id + "/v1";
    ResponseMsg<Integer> responseMsg = restClient.doDelete(SERVICE_CODE, url, new ParameterizedTypeReference<ResponseMsg<Integer>>() {
    });
    return RestClientUtils.getResponseBody(responseMsg);
  }

  public Integer deleteByIds(String[] ids) {
    String url = BASE_PATH + "/delete-by-ids/v1";
    ResponseMsg<Integer> responseMsg = restClient.doDelete(SERVICE_CODE, url, ids, new ParameterizedTypeReference<ResponseMsg<Integer>>() {
    });
    return RestClientUtils.getResponseBody(responseMsg);
  }
}
